<?php require_once './connection.php';?>
<html>
    <head>
        
    </head>    
    <body>
        <?php add(); ?>
        <?php 
            delete();
        ?>   
        <?php edit(); ?>
        <?php 
            if(isset($_POST['FIND']))
            {
                $id = $_POST['ID'];
                $sql = "select * from student WHERE ID like '%$id%'";
                $students = query($sql);
            }
            ELSE
            {
                $sql = "select * from student";
                $students = query($sql);
            }
            ?>
        <table width="200" border="5" style="color: red; background: yellow;">
            <tr>
                        <td width="50"><?php echo "ID"?></td>
                        <td width="50"><?php echo "NAME"?></td>
            </tr>
        </table>
        <?php
            foreach($students as $student):?>
                <table width="200" border="5" style="color: blue;">
                    <tr>
                        <td width="50"><?php echo $student['ID']?></td>
                        <td width="50"><?php echo $student['NAME']?></td>
                    </tr>
                </table>
            <?php endforeach; ?>    
        <form action="http://localhost:82/phat/index.php" name="Stu" method="post">
            </br>
            <table width="500">
                <tr>
                    <td>ID</td>
                    <td><input type="text" name="ID" style="width: 275px;"></td>
                </tr>
                <tr>
                    <td>NAME</td>
                    <td><input type="text" name="NAME" style="width: 275px;"></td>
                </tr>
                <tr>
                    <td></td>
                    <td>
                        <input type="submit" name="DEL" value="DELETE" style="background: cyan">
                        <input type="submit" name="ADD" value="ADD" style="background: cyan">
                        <input type="submit" name="EDIT" value="EDIT" style="background: cyan">
                        <input type="submit" name="FIND" value="FIND" style="background: cyan">
                        <input type="submit" name="LIST" value="LIST" style="background: cyan">
                    </td>
                </tr>
            </table>
          
        </form>
    </body>    
</html>